package com.example.j20240313springmvc.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

@RestController
@RequestMapping("/user")
public class LoginController {
    @RequestMapping("/login")
    public Boolean login(String userName, String password, HttpSession session) {
        //储存当前用户的Session
        session.setAttribute("name", userName);
        return "Ting-666".equals(userName) && "666777".equals(password);
    }
    @RequestMapping("/getUserName")
    public String getUserName(@SessionAttribute("name") String name){
        return name;
    }
}
